package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.Staff;
import com.pgybook.db.entity.domain.StaffEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface StaffMapper {
    int countByExample(StaffEx example);

    int deleteByExample(StaffEx example);

    @Delete({
            "delete from staff",
            "where STAFFID = #{staffid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer staffid);

    @Insert({
            "insert into staff (DEPT_ID, EMPLOYEENUM, ",
            "NAME, CELLPHONE1, ",
            "CELLPHONE2, EMAIL, ",
            "PASSWORD, ISSA, ",
            "ISSU, STATUS, CRTTIME, ",
            "UPTTIME, CRTSTAFF, ",
            "UPTSTAFF)",
            "values (#{deptId,jdbcType=INTEGER}, #{employeenum,jdbcType=VARCHAR}, ",
            "#{name,jdbcType=VARCHAR}, #{cellphone1,jdbcType=VARCHAR}, ",
            "#{cellphone2,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, ",
            "#{password,jdbcType=VARCHAR}, #{issa,jdbcType=INTEGER}, ",
            "#{issu,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{crttime,jdbcType=TIMESTAMP}, ",
            "#{upttime,jdbcType=TIMESTAMP}, #{crtstaff,jdbcType=INTEGER}, ",
            "#{uptstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "staffid", before = false, resultType = Integer.class)
    int insert(Staff record);

    int insertSelective(Staff record);

    List<Staff> selectByExample(StaffEx example);

    @Select({
            "select",
            "STAFFID, DEPT_ID, EMPLOYEENUM, NAME, CELLPHONE1, CELLPHONE2, EMAIL, PASSWORD, ",
            "ISSA, ISSU, STATUS, CRTTIME, UPTTIME, CRTSTAFF, UPTSTAFF",
            "from staff",
            "where STAFFID = #{staffid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Staff selectByPrimaryKey(Integer staffid);

    int updateByExampleSelective(@Param("record") Staff record, @Param("example") StaffEx example);

    int updateByExample(@Param("record") Staff record, @Param("example") StaffEx example);

    int updateByPrimaryKeySelective(Staff record);

    @Update({
            "update staff",
            "set DEPT_ID = #{deptId,jdbcType=INTEGER},",
            "EMPLOYEENUM = #{employeenum,jdbcType=VARCHAR},",
            "NAME = #{name,jdbcType=VARCHAR},",
            "CELLPHONE1 = #{cellphone1,jdbcType=VARCHAR},",
            "CELLPHONE2 = #{cellphone2,jdbcType=VARCHAR},",
            "EMAIL = #{email,jdbcType=VARCHAR},",
            "PASSWORD = #{password,jdbcType=VARCHAR},",
            "ISSA = #{issa,jdbcType=INTEGER},",
            "ISSU = #{issu,jdbcType=INTEGER},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPTTIME = #{upttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPTSTAFF = #{uptstaff,jdbcType=INTEGER}",
            "where STAFFID = #{staffid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Staff record);
}
